import { loginApi } from "@/api/user";
export default {
  namespaced: true,
  state: {
    token: null,
  },
  mutations: {
    getToken(state, token) {
      state.token = token;
    },
    removeToken(state) {
      state.token = null;
    },
  },
  actions: {
    async loginAction(context, data) {
      const { token } = await loginApi(data);
      console.log(token);
      context.commit("getToken", token);
    },
    logoutAction(context) {
      context.commit("removeToken");
    },
  },
};
